package com.wyz.socket.core.base.packet.file;

import com.wyz.socket.core.base.packet.AbstractSendPacket;

import java.io.*;

public class FileSendPacket extends AbstractSendPacket<FileInputStream> {

    private final File file;

    public FileSendPacket(File file) {
        this.file = file;
        length = (int) file.length();
    }

    @Override
    public byte type() {
        return TYPE_STREAM_FILE;
    }

    @Override
    protected FileInputStream createStream() {
        try {
            return new FileInputStream(file);
        } catch (FileNotFoundException e) {
            e.printStackTrace();
        }
        return null;
    }

}
